import Vue from 'vue'
import VueRouter from 'vue-router'
// import Demo from '../views/Demo'
import About from '../views/About'
// import ButtonPage from '../views/ButtonPage'
import SMS from '../views/SMS'

import Finance from '../views/home-pages/Finance'
import FinanceTwo from '../views/home-pages/FinanceTwo'
import ContactPage from '../views/ContactPage'
import ErrorPage from '../views/404'
import Help from '../views/home-pages/Help'
import Consulting from '../views/home-pages/Consulting'
import NewsContion from '../views/NewsContion.vue'    //关于我们 新闻资讯
import ProductDetails from '../views/ProductDetails.vue'    //产品中心 详情页 示例代码

import Home from '../views/home-pages/Home'
import ProductPage from '../views/ProductPage'
import innerPage from  '../views/InnerPage'

import ZMLogin from '../views/LoginARegister/ZMLogin.vue'    //账号密码登录
import SMSLogin from '../views/LoginARegister/SMSLogin.vue'    //账号密码登录
import Register from '../views/LoginARegister/Register.vue'    //注册
import RetrievePassword from '../views/LoginARegister/RetrievePassword.vue'    //找回密码
import HelpCenter from '../views/home-pages/HelpCenter.vue'    //找回密码
import NewsDetail from '../views/NewsDetail.vue'    //账号密码登录
import Feedback from '../views/Feedback.vue'
import SeekadFrom from '../views/SeekadFrom.vue'


Vue.use(VueRouter)

const routes = [
    {
        path: '/',
        name: 'Home',
        component: Home,
        meta: {
            title: '首页',
        },
    },
    {
        path: '/helper',
        name: 'Helper',
        component: Help,
        meta: {
            title: '解决方案',
        },
    },

    {
        path: '/about',
        name: 'About',
        component: About,
        meta: {
            title: '关于我们',
        },
    },
    {
        path: '/service',
        name: 'Service',
        component: SMS,
        meta: {
            title: '国际短信',
        },
    },
    {
        path: '/home',
        name: 'Home',
        component: Home,
        meta: {
            title: '首页',
        },
    },

    {
        path: '/consulting',
        name: 'Consulting',
        component: Consulting,
        meta: {
            title: '国际语音',
        },
    },
    {
        path: '/finance',
        name: 'Finance',
        component: Finance,
        meta: {
            title: '服务条款',
        },
    },
    {
        path: '/financetwo',
        name: 'Finance Two',
        component: FinanceTwo,
        meta: {
            title: '隐私协议',
        },
    },



    {
        path: '/contact',
        name: 'Contact',
        component: ContactPage,
        meta: {
            title: '联系我们',
        },
    },

    {
        path: '/error',
        name: 'Error',
        component: ErrorPage,
        meta: {
            title: '404 ',
        },
    },

    {
        path: '/product',
        name: 'Product',
        component: ProductPage,
        meta: {
            title: '产品中心',
        },
    },
    {
        path: '/inner',
        name: 'InnerPage',
        component: innerPage,
        meta: {
            title: 'api内页',
        },
    },
    {
        path: '/newscontion',
        name: 'NewsContion',
        component: NewsContion,
        meta: {
            title: '新闻中心',
        },
    },
    {
        path: '/newsdetail',
        name: 'NewsDetail',
        component: NewsDetail,
        meta: {
            title: '新闻咨询',
        },
    },
    {
        path: '/productdetails',
        name: 'ProductDetails',
        component: ProductDetails,
        meta: {
            title: '产品详情',
        },
    },

    {
        path: '/zmLogin',
        name: 'ZMLogin',
        component: ZMLogin,
        meta: {
            title: '账号密码登录',
        },
    },
    {
        path: '/smsLogin',
        name: 'SMSLogin',
        component: SMSLogin,
        meta: {
            title: '短信验证码登录',
        },
    },
    {
        path: '/register',
        name: 'Register',
        component: Register,
        meta: {
            title: '注册',
        },
    },
    {
        path: '/retrievepassword',
        name: 'RetrievePassword',
        component: RetrievePassword,
        meta: {
            title: '找回密码',
        },
    },
    {
        path: '/helpcenter',
        name: 'HelpCenter',
        component: HelpCenter,
        meta: {
            title: '帮助中心',
        },
    },
    {
        path: '/feedback',
        name: 'Feedback',
        component: Feedback,
        meta: {
            title: '意见与反馈',
        },
    },
	{
	        path: '/seekadfrom',
	        name: 'SeekadFrom',
	        component: SeekadFrom,
	        meta: {
	            title: '业务咨询',
	        },
	    },


]

const router = new VueRouter({
    mode: 'hash',
    base: process.env.BASE_URL,
    routes
})

router.beforeEach((to, from, next) => {
    // console.log('导航前的路由信息：', to);
    document.title = to.meta.title;
    next();
    window.scrollTo(0, 0)

    if (to.matched.length === 0) {//未匹配到的时候跳转到404页面
        next({ name: "Error" })
    } else {
        next()//匹配到的时候跳转相应的路由
    }

});

export default router
